package com.vito.dcs.water.device.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.vito.base.factory.IDFactory;
import com.vito.base.model.DataGrid;
import com.vito.dcs.water.device.dao.WaterStationMapper;
import com.vito.dcs.water.device.model.WaterStationModel;
import com.vito.dcs.water.device.service.WaterStationServie;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

/**
 * @program: WaterStationService
 * @description: 水稳拌合站信息表服务接口实现类
 * @author: rongr
 * @create: 2019/04/11
 */
@Service
public class WaterStationServiceImpl implements WaterStationServie {

    @Autowired
    private WaterStationMapper waterStationMapper;

    @Override
    public Integer saveWaterStation(WaterStationModel waterStationModel) {
        String waterStationId = IDFactory.getIDFactory().getIdInc("tbl_dcs_min_water_station") + "";
        waterStationModel.setWaterStationId(waterStationId);
        return waterStationMapper.saveWaterStation(waterStationModel);
    }

    @Override
    public Integer updateWaterStation(WaterStationModel waterStationModel) {
        return waterStationMapper.updateWaterStation(waterStationModel);
    }

    @Override
    public WaterStationModel queryWaterStationById(WaterStationModel waterStationModel) {
        return waterStationMapper.queryWaterStationById(waterStationModel);

    }

    @Override
    public DataGrid<WaterStationModel> queryWaterStationByPage(WaterStationModel waterStationModel) {
        DataGrid<WaterStationModel> dg = new DataGrid<WaterStationModel>();
        dg.setTotal(waterStationMapper.queryWaterStationPageCount(waterStationModel));
        dg.setRows(waterStationMapper.queryWaterStationByPage(waterStationModel));
        return dg;
    }

    @Override
    public Integer deleteStationModel(WaterStationModel waterStationModel) {
        waterStationMapper.delPoreFromStation(waterStationModel);
        waterStationMapper.delBlenderFromStation(waterStationModel);
        return waterStationMapper.deleteStationModel(waterStationModel);
    }

    @Override
    public String queryWaterPoreBlenderId(String blenderId) {
        return waterStationMapper.queryWaterPoreBlenderId(blenderId);
    }

}

